<template>
	<div class="header">
		<div class="head">
			<ul class="head-tab">
				<li 
					v-for="(item, index) in list" 
					:key="index" 
					:class="index == headActiveTab ? 'head-tab-active' : ''"
					@click="changeHeadTab(index)"
					>{{item.title}}</li>
			</ul>
			<div class="swiper-box" style="">
				<van-swipe :autoplay="3000" indicator-color="#31BC8D" style="border-radius: 10px;">
					<van-swipe-item v-for="(item, index) in bannerData" :key="index" style="background: #fff;">
						<img :src="item.picUrl" alt="">
					</van-swipe-item>
				</van-swipe>
			</div>
			<div class="zxlist">
				<div class="zx-inner" @click="toPurchases">
					<div class="img-box">
						<img src="@/assets/img/home_img01.png" alt="">
					</div>
					<div class="right-box">
						<h4>安格斯育肥牛</h4>
						<span>产业升级项目</span>
					</div>
				</div>
				<div class="zx-inner" @click="toHelpPoor">
					<div class="img-box">
						<img src="@/assets/img/home_img02.png" alt="">
					</div>
					<div class="right-box">
						<h4>新疆黑木耳</h4>
						<span>精准扶贫项目</span>
					</div>
				</div>
			</div>
			<div class="radio-box">
				<div class="img-icon">
					<img src="@/assets/img/home_img21.png" alt="">
				</div>
				<van-swipe :autoplay="4000" vertical style="height: 38px;width: 100%" :show-indicators="false" :touchable="false">
					<van-swipe-item>
						<span class="text">甘肃酒泉持续提升现代特色农业水平</span>
					</van-swipe-item>
					<van-swipe-item>
						<span class="text">新疆阿克苏：种植黑木耳增收有保障</span>
					</van-swipe-item>
				</van-swipe>
				
			</div>
		</div>
	</div>
</template>


<script>
	import Vue from 'vue';
	import { Tab, Tabs, Swipe, SwipeItem } from 'vant';
	Vue.use(Tab).use(Tabs).use(Swipe).use(SwipeItem);
	
	export default {
		props: {
			// todayPriceData: Object, // 今日报价数据
			bannerData : Array,
		},
		data(){
			return {
				active: 0,
				list: [
					{ title: '推荐' },
					{ title: '采购中心' },
					{ title: '供货中心' },
					{ title: '求购中心' },
				],
				headActiveTab: 0
			}
		},
		methods: {
			toPurchases(){
				this.$router.push({
					path: '/purchase'
				})
			},
			// 去到扶贫页面
			toHelpPoor(){
				// this.$tool.toast('页面正在开发中，敬请期待!')
				this.$router.push({
					path: '/helppoor'
				})
			},
			changeHeadTab(index) {
				this.headActiveTab = index;
				switch(index) {
					case 0:
						this.$router.push({
							path: '/'
						});
						break;
					case 1:
						this.$router.push({
							path: '/purchase'
						});
						break;
					case 2:
						this.$router.push({
							path: '/supply'
						});
						break;
					case 3:
						this.$router.push({
							path: '/buy'
						});
						break;
				}
			}
		}
	}
</script>
<style>

	.header .van-ellipsis{
		font-size: 16px !important;
	}
</style>
<style lang="scss" scoped>
	
	.radio-box{
		width: 100%;
		height: 44px;
		line-height: 44px;
		padding: 0 16px;
		margin-top: 4px;
		display: flex;
		align-items: center;
		.img-icon{
			width: 90px;
			float: left;
			img{
				width: 100%;
				vertical-align: middle;
			}
		}
		.text{
			float: left;
			margin-left: 30px;
			color: #666666;
			font-size: 12px;
		}
	}
	.zxlist{
		width: 100%;
		height: 69px;
		display: flex;
		padding: 0 12px;
		.zx-inner{
			display: flex;
			flex: 1;
			align-items: center;
			justify-content: center;
			box-shadow:0px 0px 15px #D7DDDB;
			.img-box{
				width: 41px;
				float: left;
				img{
					width: 100%;
					vertical-align: middle;
				}
			}
			.right-box{
				margin-left: 10px;
				h4{
					color: #344047;
					margin-bottom: 10px;
				}
				span{
					color: #969C9E;
					font-size: 12px;
				}
			}
		}
		.zx-inner:first-child {
			margin-right: 10px;
		}
	}
	.swiper-box{
		width: 100%;
		padding: 10px 12px;
		box-sizing: border-box;
		img{
			display: block;
			width: 100%;
		}
	}
	.head{
		width: 100%;
		background-color: #fff;

		.head-tab {
			width: 100%;
			height: 44px;
			padding: 0 26px;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;
			align-items: center;
			li {
				height: 44px;
				line-height: 44px;
				color: #5D6164;
				font-size: 16px;
				box-sizing: border-box;
				&.head-tab-active {
					position: relative;
					color: #31BC8D;
					font-weight: 500;
					&::after {
						content: "";
						position: absolute;
						bottom: 0;
						left: 0;
						width: 100%;
						height: 2px;
						background-color: #31BC8D;
					}
				}
			}
		}
		
		.header-list {
			width: 100%;
			height: 56px;
			line-height: 56px;
			display: flex;
			justify-content: center;
			align-items: center;
			
			li{
				width: 25%;
				text-align: center;
				color: #5D6164;
			}
		}
	}
	
	
	
</style>
